package com.ning.cloud.common.exception;


import com.ning.cloud.common.enums.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 通用业务异常
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {

    /**
     * 业务错误码
     */
    private Integer code;


    /**
     * 错误提示
     */
    private String message;

    public ServiceException() {
        this(ErrorCode.FAIL.getCode(), ErrorCode.FAIL.getMessage());
    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getMessage());
    }


    public ServiceException(String message) {
        this(ErrorCode.FAIL.getCode(), message);
    }

}
